package com.financing.platform.service.impl;



import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IFpHdFinancingBlindDao;
import com.financing.platform.dto.FpHdFinancingBlindDTO;
import com.financing.platform.service.IFpHdFinancingBlindService;
/**
 * fp_hd_financing_blind  
 * sfa活动-金融相亲表 业务访问层实现类
 * @author lisu
 *
 */
 
@Repository("fpHdFinancingBlindService")
public class FpHdFinancingBlindServiceImpl implements IFpHdFinancingBlindService{

	@Autowired
	private IFpHdFinancingBlindDao fpHdFinancingBlindDao;

	@Override
	public int insert(FpHdFinancingBlindDTO fpHdFinancingBlind) throws SQLException {
		return fpHdFinancingBlindDao.insert(fpHdFinancingBlind);
	}

	@Override
	public void update(Map<String, Object> map) throws SQLException {
		fpHdFinancingBlindDao.update(map);
	}

	@Override
	public void updateForce(FpHdFinancingBlindDTO fpHdFinancingBlind) throws SQLException {
		fpHdFinancingBlindDao.updateForce(fpHdFinancingBlind);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		fpHdFinancingBlindDao.delete(id);
	}
	
	@Override
	public List<FpHdFinancingBlindDTO> queryList(FpHdFinancingBlindDTO fpHdFinancingBlind) throws SQLException {
		
		String orderParameter = fpHdFinancingBlind.getOrderParameter();
		//01 添加时间02修改时间03 真实数据
		if("01".equals(orderParameter)){
			orderParameter = "CREATE_DATE";
 		}else{
 			orderParameter = "id";
 		}
		fpHdFinancingBlind.setOrderParameter(orderParameter);
		
		
		String orderType = fpHdFinancingBlind.getOrderType();
		//01 降序 02 升序
		if("01".equals(orderType)){
			orderType = "desc";
 		}else if("02".equals(orderType)){
 			orderType = "asc";
 		}else{
 			orderType = "desc";
 		}
		fpHdFinancingBlind.setOrderType(orderType);
		
		return fpHdFinancingBlindDao.queryList(fpHdFinancingBlind);
	}

	@Override
	public int queryListCount(FpHdFinancingBlindDTO fpHdFinancingBlind) throws SQLException {
		return fpHdFinancingBlindDao.queryListCount(fpHdFinancingBlind);
	}

	@Override
	public FpHdFinancingBlindDTO loadById(Integer id) throws SQLException {
		return fpHdFinancingBlindDao.loadById(id);
	}
 	@Override
	public FpHdFinancingBlindDTO queryListGetFirst(FpHdFinancingBlindDTO fpHdFinancingBlind)
			throws SQLException {
		 List<FpHdFinancingBlindDTO> queryList = queryList(fpHdFinancingBlind);
		 if(queryList==null||queryList.size()==0){
			 return new FpHdFinancingBlindDTO();
		 }
		 return queryList.get(0);
	}
}
